home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 235_01 / biosio.asm < prev    next >
Assembly Source File  |  1987-06-16  |  6KB  |  221 lines

  1.         PAGE   60,132
  2.         TITLE  Routines to do bios screen I/O
  3.  
  4. ;  002  30-Jan-87  biosio.asm
  5.  
  6. ;       Copyright (c) 1986 by Blue Sky Software.  All rights reserved.
  7.  
  8.  
  9. _TEXT   SEGMENT  BYTE PUBLIC 'CODE'
  10. _TEXT   ENDS
  11. CONST   SEGMENT  WORD PUBLIC 'CONST'
  12. CONST   ENDS
  13. _BSS    SEGMENT  WORD PUBLIC 'BSS'
  14. _BSS    ENDS
  15. _DATA   SEGMENT  WORD PUBLIC 'DATA'
  16. _DATA   ENDS
  17.  
  18. DGROUP  GROUP   CONST,  _BSS,   _DATA
  19.         ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  20.  
  21. _TEXT      SEGMENT
  22.  
  23. ;******************************************************************************
  24. ;
  25. ;  getvideomode(width,page)       get the current video mode/width/page
  26. ;  int *width, *page;
  27. ;
  28. ;******************************************************************************
  29.  
  30.         PUBLIC _getvideomode
  31.  
  32. _getvideomode PROC NEAR
  33.         push   bp
  34.         mov    bp,sp
  35.  
  36.         mov    ah,0fh                  ; just use bios int 10h - 15
  37.         int    10h
  38.  
  39.         mov    cl,bh                   ; save page # (bh)
  40.         xor    ch,ch
  41.         mov    bx,[bp+6]               ; page pointer
  42.         mov    [bx],cx
  43.  
  44.         mov    cl,ah                   ; current width
  45.         mov    bx,[bp+4]               ; width pointer
  46.         mov    [bx],cx
  47.  
  48.         xor    ah,ah                   ; al already has the mode
  49.  
  50.         mov    sp,bp
  51.         pop    bp
  52.         ret
  53.  
  54. _getvideomode ENDP
  55.  
  56.  
  57. ;******************************************************************************
  58. ;
  59. ;  setvideomode(mode)             set the current video mode
  60. ;  int mode;
  61. ;
  62. ;******************************************************************************
  63.  
  64.         PUBLIC _setvideomode
  65.  
  66. _setvideomode PROC NEAR
  67.         push   bp
  68.         mov    bp,sp
  69.  
  70.         mov    ah,0                    ; just use bios int 10h - 0
  71.         mov    al,[bp+4]               ; low byte of mode
  72.         int    10h
  73.  
  74.         mov    sp,bp
  75.         pop    bp
  76.         ret
  77.  
  78. _setvideomode ENDP
  79.  
  80.  
  81. ;******************************************************************************
  82. ;
  83. ;  readcursor(page,row,col,stscan,endscan)  /* read cursor info */
  84. ;  int page;
  85. ;  int *row, *col, *stscan, *endscan;
  86. ;
  87. ;******************************************************************************
  88.  
  89.         PUBLIC _readcursor
  90.  
  91. _readcursor  PROC NEAR
  92.         push   bp
  93.         mov    bp,sp
  94.  
  95.         mov    ah,3                    ; just use bios int 10h - 3
  96.         mov    bh,[bp+4]               ; low byte of page
  97.         int    10h
  98.  
  99.         xor    ah,ah
  100.         mov    al,dh                   ; cursor row
  101.         mov    bx,[bp+6]
  102.         mov    [bx],ax
  103.  
  104.         mov    al,dl                   ; cursor column
  105.         mov    bx,[bp+8]
  106.         mov    [bx],ax
  107.  
  108.         mov    al,ch                   ; cursor start scan line
  109.         mov    bx,[bp+10]
  110.         mov    [bx],ax
  111.  
  112.         mov    al,cl                   ; cursor end scan line
  113.         mov    bx,[bp+12]
  114.         mov    [bx],ax
  115.  
  116.         mov    sp,bp
  117.         pop    bp
  118.         ret
  119.  
  120. _readcursor ENDP
  121.  
  122.  
  123. ;******************************************************************************
  124. ;
  125. ;  setcursorsize(startscan,endscan)   /* set cursor size */
  126. ;  int startscan, endscan;
  127. ;
  128. ;******************************************************************************
  129.  
  130.         PUBLIC _setcursorsize
  131.  
  132. _setcursorsize PROC   NEAR
  133.         push   bp
  134.         mov    bp,sp
  135.  
  136.         mov    ah,1                    ; just use DOS int 10h - 1
  137.         mov    ch,[bp+4]               ; starting scan line
  138.         mov    cl,[bp+6]               ; ending scan line
  139.         int    10h
  140.  
  141.         mov    sp,bp
  142.         pop    bp
  143.         ret
  144. _setcursorsize ENDP
  145.  
  146.  
  147. ;******************************************************************************
  148. ;
  149. ;  setdisplaypage(page)                /* set current display page # */
  150. ;  int page;
  151. ;
  152. ;******************************************************************************
  153.  
  154.         PUBLIC _setdisplaypage
  155.  
  156. _setdisplaypage PROC   NEAR
  157.         push   bp
  158.         mov    bp,sp
  159.  
  160.         mov    ah,5                    ; just use DOS int 10h - 5
  161.         mov    al,[bp+4]               ; wanted display page #
  162.         int    10h
  163.  
  164.         mov    sp,bp
  165.         pop    bp
  166.         ret
  167. _setdisplaypage ENDP
  168.  
  169.  
  170. ;******************************************************************************
  171. ;
  172. ;  getraw()       get a char from console without ^C checking
  173. ;
  174. ;******************************************************************************
  175.  
  176.         PUBLIC _getraw
  177.  
  178. _getraw PROC   NEAR
  179.         push   bp
  180.         mov    bp,sp
  181.  
  182.         mov    ah,7                    ; just use DOS int 21h - 7
  183.         int    21h
  184.         xor    ah,ah
  185.  
  186.         mov    sp,bp
  187.         pop    bp
  188.         ret
  189. _getraw ENDP
  190.  
  191.  
  192. ;******************************************************************************
  193. ;
  194. ;  peekchr()      peek a char from console without removing from buffer
  195. ;
  196. ;******************************************************************************
  197.  
  198.         PUBLIC _peekchr
  199.  
  200. _peekchr PROC  NEAR
  201.         push   bp
  202.         mov    bp,sp
  203.  
  204.         mov    ah,1                    ; just use BIOS int 16h - 1
  205.         int    16h
  206.         jz     nochr                   ; Z means no char waiting
  207.  
  208.         xor    ah,ah                   ; got a char in al, clr ah
  209.         jmp    SHORT peekret
  210.  
  211. nochr:  xor    ax,ax                   ; tell caller no char
  212.  
  213. peekret: mov   sp,bp
  214.         pop    bp
  215.         ret
  216. _peekchr ENDP
  217.  
  218.  
  219. _TEXT   ENDS
  220.         END
  221.